DatabaseField Class
Used to access the values of fields in a record in a database table.
More information available in parent classes: Object
Notes
Assignments to the DateValue property store the time as well as the date, as with DatabaseRecords. When getting a value, the resulting Date object may contain a time as well as a date. For fields of type Date, the time will be 00:00:00 (midnight); and for fields of type Time, the date will be January 1, 0001. Fields of type TimeStamp contain valid data for both the date and time.
The conversion operator, Operator_Convert, has been added to StringValue, BooleanValue, DateValue, IntegerValue, and DoubleValue.
Examples
The following example uses the Value property to set the values of fields of different data types.
Dim rs as RecordSet
rs = MyDB.SQLSelect("select * from mytable")
rs.Edit
rs.field("MyName").value = Nil // NULL this field,
//does not work for all database plugins
rs.field("MyID").value = 23
rs.field("MyText").value = "Test"
rs.update
MyDB.Commit
The following method populates a ListBox with a RecordSet. It uses the Name and StringValue properties to obtain the fieldnames and values:
Dim i as Integer
Dim v as String
ListBox1.deleteAllRows
ListBox1.columncount = d.fieldcount
ListBox1.addrow d.IdxField(1).Name
ListBox1.cellBold(ListBox1.lastIndex, 0) = true
for i = 2 to d.fieldcount
ListBox1.cell(ListBox1.lastIndex,i-1) =d.IdxField(i).name
ListBox.cellBold( ListBox.lastIndex, i-1) = true
next
While not d.eof
v = d.IdxField(1).StringValue
ListBox1.addrow v
For i = 2 to d.fieldcount
ListBox.cell( ListBox.lastIndex,i-1)=d.IdxField(i).StringValue
next
d.MoveNext
wend
See Also
Database, DatabaseRecord, RecordSet classes.